package cn.zysuyuan.item.utils;

/**
 * @author flypig
 * @version 1.0
 * @date 2020-02-20 20:21
 */

import cn.zysuyuan.common.entity.Constant;
import org.apache.commons.io.FileUtils;
import org.springframework.scheduling.annotation.Async;

import java.io.File;
import java.io.IOException;

/**
 * 保存归档文件
 */
public class HandleEditionFile {

    public  void CopeFile(String name) {
        String path = Constant.IMG_PATH;
        File srcFIle = new File(path);
        String editionPath = path + name;
        File targetFile = new File(editionPath);
        File[] files = srcFIle.listFiles();
        for (File item : files) {
            if (item.isFile()) {
                try {
                    FileUtils.copyFileToDirectory(item, targetFile);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void DeleteFile(String name) {
        String path = Constant.IMG_PATH;
        String editionPath = path + name;
        File targetFile = new File(editionPath);
        FileUtils.deleteQuietly(targetFile);
    }

}
